<?php
    require_once "Basic.php";
    class Friend extends Basic{
        private $tableName = 'timeBlock.friend';
        public function add($arguments){
            $res = $this->dbHandle->insert($this->tableName, ['name' => $this->encryptStr($arguments['name']), 'desc' => $this->encryptStr($arguments['desc'])]);
            return $res;
        }

        public function allFriend(){
            $res = $this->dbHandle->select($this->tableName);
            $result = [];
            foreach ($res as $key => $value){
                $tempArr = [];
                $tempArr['name'] = $this->decryptStr(($value->name));
                $tempArr['_id'] = (string)$value->_id;
                array_push($result, $tempArr);
            }
            return $result;
        }
    }